package tests;

import static org.junit.Assert.*;

import model.subjects.Person;

import org.junit.Before;
import org.junit.Test;
import org.junit.Assert.*;

import database.dao.PersonDAO;

public class PersonDaoTest {

	@Test
	public void testFindPersonFromDB() {

		Person p = null;
		PersonDAO dao = new PersonDAO();

		p = dao.findPersonFromDB(2);
		assertEquals(2, p.getId());
		assertEquals("Martu", p.getFirst_name());
		assertEquals("Maasikas", p.getLast_name());

	}

	@Test
	public void testGetPeopleByFirstNameFromDB() {

		Person[] p = null;
		PersonDAO dao = new PersonDAO();
		String firstName = "Martu";

		p = dao.getPeopleByFirstNameFromDB(firstName);

		for (int i = 0; i < p.length; i++) {

			assertEquals(2, p[i].getId());

			assertEquals("Martu", p[i].getFirst_name());
			assertEquals("Maasikas", p[i].getLast_name());

		}

	}

}
